import React, { useState } from 'react';
import { Modal, Radio, RadioChangeEvent, Space } from 'antd';
import { useTranslation } from 'react-i18next';
import AgentService, { IStreamMode } from '@/modules/Agent';

const AccpetCallMode = (props: { visible: boolean; cancel: () => void; ok: (value: IStreamMode) => void }) => {
	const { t, i18n } = useTranslation();
	const onChange = (e: RadioChangeEvent) => {
		setValue(e.target.value);
	};
	const handleOk = () => {
		props.ok(value);
	};
	const [value, setValue] = useState(AgentService.acceptCallMode.receiveMediaType);
	return (
		<Modal title={t('accept-call-set')} open={props.visible} onOk={handleOk} onCancel={props.cancel} maskClosable={false} okText={t('sure')} cancelText={t('cancel')}>
			<Radio.Group onChange={onChange} value={value} className="accept-call-modal">
				<Space direction="vertical">
					<Radio value={'video'}>{t('accept-video')}</Radio>
					<Radio value={'audio'}>{t('accept-audio')}</Radio>
				</Space>
			</Radio.Group>
		</Modal>
	);
};

export default AccpetCallMode;
